package com.dingding.common.core.push.factory;

import org.springframework.beans.BeanUtils;

import com.dingding.common.core.beans.UserTaxiOrdert;
import com.dingding.common.core.beans.Userdetail;
import com.dingding.common.core.beans.special.UserspecialorderT;
import com.dingding.common.core.push.factory.dtos.OrderDurationDTO;
import com.dingding.common.core.push.pushbean.specialdriver.AppointSpecialOrderPushBean;
import com.dingding.common.core.push.pushbean.specialdriver.AppointTaxiOrderPushBean;
import com.dingding.common.core.push.pushbean.specialdriver.CustomerCancelSpecialOrderPush;
import com.dingding.common.core.util.DateFormatUtil;
import com.dingding.common.core.util.ToolUtil;

/**
 * @Description:推送的bean的生产者
 * @author fengshuonan
 * @date 2016年8月23日 下午6:54:30
 * @version 叮叮搭车
 * @since 2.4
 */
public class PushBeanFactory {

	/**
	 * @Description 指派出租车订单的推送
	 * @author fengshuonan
	 */
	public static AppointTaxiOrderPushBean appointTaxiOrderPushBean(Userdetail userdetail, UserTaxiOrdert taxiOrdert,
			OrderDurationDTO orderDurationDTO) {
		AppointTaxiOrderPushBean taxiOrderPushBean = new AppointTaxiOrderPushBean();
		taxiOrderPushBean.setTelePhone(userdetail.getTellphone());
		taxiOrderPushBean.setOtherUserId(userdetail.getLoginId());
		taxiOrderPushBean.setOutTime(DateFormatUtil.getMMddEHHss(taxiOrdert.getSetOutTime()));
		taxiOrderPushBean.setOid(taxiOrdert.getTaxiOrdertId());
		BeanUtils.copyProperties(userdetail, taxiOrderPushBean);
		BeanUtils.copyProperties(taxiOrdert, taxiOrderPushBean);
		BeanUtils.copyProperties(orderDurationDTO, taxiOrderPushBean);
		taxiOrderPushBean.setDistance(taxiOrdert.getDistance());
		taxiOrderPushBean.setUserAvatar(ToolUtil.imageAddress(userdetail.getUserAvatar()));
		taxiOrderPushBean.setUserTabloidAvatar(ToolUtil.imageAddress(userdetail.getUserTabloidAvatar()));
		taxiOrderPushBean.setPublishType(2);
		return taxiOrderPushBean;
	}

	/**
	 * @Description:生成指派专车订单的推送bean（推给车主）
	 * @param userdetail
	 *            用户信息详情（乘客的）
	 * @param userspecialorderT
	 *            订单详情
	 * @param orderDurationDTO
	 *            订单里程信息
	 * @author fengshuonan
	 * @return AppointSpecialOrderPushBean 生产出来的指派专车订单推送
	 * @since 2.4
	 */
	public static AppointSpecialOrderPushBean getAppointSpecialOrderPushBean(Userdetail userdetail,
			UserspecialorderT userspecialorderT, OrderDurationDTO orderDurationDTO) {
		AppointSpecialOrderPushBean appointSpecialOrderPushBean = new AppointSpecialOrderPushBean();
		appointSpecialOrderPushBean.setTelePhone(userdetail.getTellphone());
		appointSpecialOrderPushBean.setOtherUserId(userdetail.getLoginId());
		appointSpecialOrderPushBean.setOutTime(DateFormatUtil.getMMddEHHss(userspecialorderT.getSetOutTime()));
		appointSpecialOrderPushBean.setOid(userspecialorderT.getSpecialOrderId());
		BeanUtils.copyProperties(userdetail, appointSpecialOrderPushBean);
		BeanUtils.copyProperties(userspecialorderT, appointSpecialOrderPushBean);
		BeanUtils.copyProperties(orderDurationDTO, appointSpecialOrderPushBean);
		appointSpecialOrderPushBean.setEstimateDistance(userspecialorderT.getEstimateDistance());
		appointSpecialOrderPushBean.setDistance(userspecialorderT.getDistance());
		appointSpecialOrderPushBean.setEstimateMoney(userspecialorderT.getEstimateMoney());
		appointSpecialOrderPushBean.setEstimateDuration(userspecialorderT.getEstimateDuration());
		appointSpecialOrderPushBean.setUserAvatar(ToolUtil.imageAddress(userdetail.getUserAvatar()));
		appointSpecialOrderPushBean.setUserTabloidAvatar(ToolUtil.imageAddress(userdetail.getUserTabloidAvatar()));
		return appointSpecialOrderPushBean;
	}

	/**
	 * @Description:获取乘客的取消订单推送(推送给车主的)
	 * @author fengshuonan
	 * @since 2.4
	 */
	public static CustomerCancelSpecialOrderPush getCustomerCancelSpecialOrderBean(String oid, Integer orderStatus,
			Integer publishType) {
		CustomerCancelSpecialOrderPush cancelSpecialOrderPush = new CustomerCancelSpecialOrderPush();
		cancelSpecialOrderPush.setOid(oid);
		cancelSpecialOrderPush.setOrderStatus(orderStatus);
		cancelSpecialOrderPush.setPublishType(publishType);
		return cancelSpecialOrderPush;
	}
}
